package com.tan.controller;

import com.tan.domain.User;
import com.tan.domain.response.Result;
import com.tan.domain.response.StatusCode;
import com.tan.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @description:
 * @author: longshifu
 * @time: 2022/7/12 22:30
 */
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping(value = "/login")
    public Result login(@RequestBody Map<String, User> para) {
        Result result = userService.login(para);
        return new Result(true, StatusCode.OK, result.getMessage(), result.getData());
    }

    @PostMapping("/register")
    public Result register(@RequestBody Map<String, User> param) {
        Result result = userService.register(param);
        return new Result(true, StatusCode.OK, result.getMessage(), result.getData());
    }


}
